// pages/personnel/index/news/delivery/delivery.js
import {openDocument} from "../../../../../utils/Wx";
import {downloadFile} from "../../../../../service/Common";
import Toast from "@vant/weapp/toast/toast";
Component({

    /*
    * 默认接收全局样式
    * */
    options: {
        addGlobalClass: true
    },

    /**
     * 组件的属性列表
     */
    properties: {
        itemInfo: {
            type: Object,
            value: {}
        }
    },

    /**
     * 组件的初始数据
     */
    data: {

    },

    /**
     * 组件的方法列表
     */
    methods: {
        bindShowResume: async function () {
            try {
                let path = this.data.itemInfo.resume;
                Toast.loading({
                    message: "下载中...",
                    duration: 0,
                    context: this
                });
                let tempFilePath = await downloadFile(path);
                Toast.clear();
                Toast.loading({
                    message: "打开中...",
                    duration: 0,
                    context: this,

                });
                await openDocument(tempFilePath);
                Toast.clear();
            } catch (e) {
                Toast({
                    type: "fail",
                    message: "打开失败！",
                    context: this
                })
                console.error(e)
            }
        }
    }
})
